<template>
  <div class="allOrderContainer">
    <div class="content-wrapper">
      <div class="actions" style="margin-bottom: 10px">
        <div class="left" :key="tabIndex">
          <!-- 0 自提 1 送货--待签收   2 --已签收  3--已拒收 -->
          <template v-if="tabIndex === '0' || tabIndex === '1'">
            <el-button
              id="sign_create_button"
              data-tracker="P10-2"
              type="primary"
              plain
              size="mini"
              @click="handleClickSign('0')"
              v-permission="'waybillSign_create'"
              >签收</el-button
            >
            <el-button
              id="un_sign_create_button"
              data-tracker="P10-5"
              type="primary"
              plain
              size="mini"
              @click="handleClickSign('1')"
              v-permission="'waybillSign_create'"
              >拒收</el-button
            >
          </template>
          <template v-if="tabIndex === '2'">
            <el-button
              data-tracker="P10-1"
              type="primary"
              plain
              size="mini"
              @click="handleClickCancel"
              v-permission="'waybillSign_cancelSign_update'"
              >取消签收</el-button
            >
          </template>
          <template v-if="tabIndex === '3'">
            <el-button
              data-tracker="P10-7"
              type="primary"
              plain
              size="mini"
              @click="handleClickCancel"
              v-permission="'waybillSign_cancelSign_update'"
              >取消拒收</el-button
            >
          </template>
          <el-button
            type="primary"
            :key="tabIndex"
            :loading="isLoading"
            plain
            size="mini"
            @click="handleExport()"
            v-permission="
              tabIndex === '0'
                ? 'waybill_sign_take_stay_export'
                : tabIndex === '1'
                ? 'waybill_sign_delivery_stay_export'
                : 'waybill_sign_export'
            "
            >导出</el-button
          >
        </div>
        <div class="right">
          <div v-if="tabIndex === '0' || tabIndex === '1'">
            <div style="display: flex">
              <el-button
                type="primary"
                icon="el-icon-refresh"
                data-tracker="P10-4"
                @click="handleSignReset"
                style="margin-right: 10px"
                >重置
              </el-button>
              <SettinUp
                :settype="1"
                :objSettinUpdata="objSettinUp"
                key="1"
              ></SettinUp>
            </div>
          </div>
          <div v-else>
            <div style="display: flex">
              <el-button
                type="primary"
                icon="el-icon-refresh"
                data-tracker="P10-4"
                @click="handleSignReset"
                style="margin-right: 10px"
                >重置
              </el-button>
              <SettinUp
                :settype="6"
                :objSettinUpdata="objSettinUp"
                key="2"
              ></SettinUp>
            </div>
          </div>
          <!-- <el-pagination
            small
            :current-page="paginations.pageIndex"
            :page-sizes="paginations.pageSizes"
            :page-size="paginations.pageSize"
            :layout="paginations.layout"
            :total="paginations.total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          /> -->
        </div>
      </div>
      <div>
        <div
          v-if="
            (tabIndex === '0' || tabIndex === '1') &&
            header_data_list.length > 0
          "
        >
          <TableHeader
            ref="TableHeaderList"
            :header_data_list="header_data_list"
            :HeaderData="HeaderData"
            :propMap="propMap"
            :objheader="objheader"
            @childEvent="handleDelete"
            @orderIdNumsEvent="handleDeleteType"
            :key="tabIndex"
          ></TableHeader>
        </div>
        <div v-else-if="tabIndex === '2' && header_data_list_two.length > 0">
          <TableHeader
            ref="TableHeaderList"
            :header_data_list="header_data_list_two"
            :HeaderData="HeaderData_two"
            :propMap="propMap_two"
            :objheader="objheader_two"
            @childEvent="handleDelete_two"
            @orderIdNumsEvent="handleDeleteType_two"
            :operation_type="operation_type"
            @handleClickDetail_three="handleClickDetail_three"
            @handleClickEdit_three="handleClickEdit_three"
            @clickabnormalFn_three="clickabnormalFn_three"
            @childEventJupway="handleJumpway"
            particulars="waybillSign_detail"
            redact="waybillSign_update"
            modification="abnormal_record_create"
            :key="tabIndex"
          ></TableHeader>
        </div>
        <div v-else-if="tabIndex === '3' && header_data_list_three.length > 0">
          <TableHeader
            ref="TableHeaderList"
            :header_data_list="header_data_list_three"
            :HeaderData="HeaderData_three"
            :propMap="propMap_three"
            :objheader="objheader_three"
            @childEvent="handleDelete_three"
            :operation_type="operation_type"
            @orderIdNumsEvent="handleDeleteType_three"
            @handleClickDetail_three="handleClickDetail_three"
            @handleClickEdit_three="handleClickEdit_three"
            @clickabnormalFn_three="clickabnormalFn_three"
            @childEventJupway="handleJumpway"
            particulars="waybillSign_detail"
            redact="waybillSign_update"
            modification="abnormal_record_create"
            :key="tabIndex"
          ></TableHeader>
        </div>

        <!-- <el-table
            id="filter_box"
          key="tabIndex"
          :data="orders"
          ref="multipleTable"
          border
          :row-key="(item) => item.id"
          stripe
          align="center"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          :cell-style="rowStyle"
          v-if="tabIndex === '0' || tabIndex === '1'"
        >
          <el-table-column
            type="selection"
            width="45"
            :reserve-selection="true"
          >
          </el-table-column>
          <el-table-column
            prop=""
            fixed
            label="序号"
            width="50"
            type="index"
          ></el-table-column>
          <el-table-column prop="waybill_no" fixed label="运单号" width="180">
            <template slot-scope="scope">
              <span
                style="cursor: pointer; color: blue"
                @click="handleJump(scope.row.id)"
                >{{ scope.row.waybill_no }}
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="receiver_company" label="收货公司" width="180">
          </el-table-column>
          <el-table-column prop="receiver_name" label="收货人" width="180">
          </el-table-column>
          <el-table-column
            prop="receiver_phone"
            label="收货人手机号"
            width="180"
          >
          </el-table-column>
          <el-table-column prop="receiver_address" label="收货地址" width="260">
          </el-table-column>
          <el-table-column
            prop="waybill_product_type_name"
            label="承运类型"
            width="120"
          >
          </el-table-column>
          <el-table-column prop="status" label="运单状态" width="100">
            <template slot-scope="scope">
              {{ statusArr[scope.row.status] }}
            </template>
          </el-table-column>
          <el-table-column prop="from_area_name" label="出发区域" width="180">
          </el-table-column>
          <el-table-column prop="to_area_name" label="目的区域" width="180">
          </el-table-column>
          <el-table-column
            prop="from_network_name"
            label="出发网点"
            width="180"
          >
          </el-table-column>
          <el-table-column prop="to_network_name" label="目的网点" width="180">
          </el-table-column>
          <el-table-column prop="sender_company" label="发货公司" width="180">
          </el-table-column>
          <el-table-column prop="sender_name" label="发货人" width="180">
          </el-table-column>
          <el-table-column prop="sender_phone" label="发货人手机号" width="180">
          </el-table-column>
          <el-table-column prop="sender_address" label="发货地址" width="260">
          </el-table-column>

          <el-table-column prop="create_time" label="创建时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.create_time"></span>
            </template>
          </el-table-column>
          <el-table-column prop="total_goods_cnt" label="总件数" width="80">
          </el-table-column>
          <el-table-column prop="thermosphere_name" label="温层" width="140">
          </el-table-column>
          <el-table-column prop="from_region_name" label="发站" width="180">
          </el-table-column>
          <el-table-column prop="to_region_name" label="到站" width="100">
          </el-table-column>
          <el-table-column prop="router" label="路由" width="180">
          </el-table-column>
          <el-table-column prop="handler_name" label="经办人" width="100">
          </el-table-column>
          <el-table-column prop="total_freight" label="总运费" width="100">
          </el-table-column>
          <el-table-column prop="receipt_count" label="客户回单" width="80">
            <template slot-scope="scope">
              {{
                scope.row.receipt_count === "1" ||
                scope.row.receipt_count === "3"
                  ? "是"
                  : "否"
              }}
            </template>
          </el-table-column>
          <el-table-column prop="receipt_count" label="我司回单" width="80">
            <template slot-scope="scope">
              {{
                scope.row.receipt_count === "2" ||
                scope.row.receipt_count === "3"
                  ? "是"
                  : "否"
              }}
            </template>
          </el-table-column>
          <el-table-column prop="remark" label="备注" width="180">
          </el-table-column>
          <el-table-column prop="last_editor_name" label="操作人" width="100">
          </el-table-column>
          <el-table-column prop="customer_id_name" label="所属客户" width="100">
          </el-table-column>
          <el-table-column
            prop="customer_area_name"
            label="客户所属大区"
            show-overflow-tooltip
            width="120"
          >
          </el-table-column>
          <el-table-column prop="update_time" label="操作时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.update_time"></span>
            </template>
          </el-table-column>
        </el-table> -->
        <!-- <el-table
            id="filter_box_2"
          key="2"
          ref="multipleTable"
          :data="orders"
          border
          stripe
          align="center"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          v-else-if="tabIndex === '2'"
        >
          <el-table-column type="selection" width="45"> </el-table-column>
          <el-table-column type="index" fixed label="序号" width="50">
          </el-table-column>
          <el-table-column prop="batch" label="签收批次" width="180">
          </el-table-column>
          <el-table-column prop="waybill_no" label="运单号" width="200">
            <template slot-scope="scope">
              <span
                style="cursor: pointer; color: blue"
                @click="handleJump(scope.row.waybill_id)"
                >{{ scope.row.waybill_no }}
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="sign_name" label="签收人" width="180">
          </el-table-column>
          <el-table-column prop="sign_time" label="签收时间" width="200">
          </el-table-column>
          <el-table-column
            prop="from_network_name"
            label="出发网点"
            width="180"
          >
          </el-table-column>
          <el-table-column prop="to_network_name" label="目的网点" width="180">
          </el-table-column>
          <el-table-column prop="delivery_method" label="送货方式" width="180">
          </el-table-column>
          <el-table-column prop="sender_name" label="发货人" width="180">
          </el-table-column>
          <el-table-column prop="sender_phone" label="发货人手机号" width="180">
          </el-table-column>
          <el-table-column prop="receiver_name" label="收货人" width="180">
          </el-table-column>
          <el-table-column
            prop="receiver_phone"
            label="收货人手机号"
            width="180"
          >
          </el-table-column>
          <el-table-column prop="number" label="件数" width="180">
          </el-table-column>
          <el-table-column prop="weight" label="重量（kg）" width="180">
          </el-table-column>
          <el-table-column prop="volume" label="体积（m³）" width="180">
          </el-table-column>
          <el-table-column prop="branch_name" label="签收网点" width="180">
          </el-table-column>
          <el-table-column prop="last_editor_name" label="操作人" width="180">
          </el-table-column>
          <el-table-column prop="update_time" label="操作时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.update_time"></span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="160" fixed="right" align="center">
            <template slot-scope="scope">
              <el-button
                size="small"
                type="text"
                @click="handleClickEdit(scope.row, 'detail')"
                v-permission="'waybillSign_detail'"
                >详情</el-button
              >
              <el-button
                size="small"
                type="text"
                @click="handleClickEdit(scope.row, 'edit')"
                v-permission="'waybillSign_detail'"
                >编辑</el-button
              >
              <el-button
              v-permission="'waybillSign_detail'"
                type="text"
                size="small"
                @click="clickabnormalFn(scope.row)"
                >异常操作</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <el-table
            id="filter_box_3"
          :key="tabIndex + '-'"
          ref="multipleTable"
          :data="orders"
          border
          stripe
          align="center"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          v-else-if="tabIndex === '3'"
        >
          <el-table-column type="selection" width="45"> </el-table-column>
          <el-table-column type="index" fixed label="序号" width="50">
          </el-table-column>
          <el-table-column prop="batch" label="拒收批次" width="180">
          </el-table-column>
          <el-table-column prop="waybill_no" label="运单号" width="200">
            <template slot-scope="scope">
              <span
                style="cursor: pointer; color: blue"
                @click="handleJump(scope.row.waybill_id)"
                >{{ scope.row.waybill_no }}
              </span>
            </template>
          </el-table-column>
          <el-table-column prop="sign_name" label="拒收人" width="200">
          </el-table-column>
          <el-table-column prop="reject_type" label="拒收类型" width="180">
            <template slot-scope="scope">
              {{ rejectData[scope.row.reject_type] }}
            </template>
          </el-table-column>
          <el-table-column prop="reject_reason" label="拒收原因" width="200">
          </el-table-column>
          <el-table-column prop="sender_name" label="发货人" width="180">
          </el-table-column>
          <el-table-column prop="sender_phone" label="发货人手机号" width="180">
          </el-table-column>
          <el-table-column prop="receiver_name" label="收货人" width="180">
          </el-table-column>
          <el-table-column
            prop="receiver_phone"
            label="收货人手机号"
            width="180"
          >
          </el-table-column>
          <el-table-column prop="number" label="件数" width="180">
          </el-table-column>
          <el-table-column prop="weight" label="重量（kg）" width="180">
          </el-table-column>
          <el-table-column prop="volume" label="体积（m³）" width="180">
          </el-table-column>
          <el-table-column prop="branch_name" label="签收网点" width="180">
          </el-table-column>
          <el-table-column prop="last_editor_name" label="操作人" width="180">
          </el-table-column>
          <el-table-column prop="update_time" label="操作时间" width="180">
            <template slot-scope="scope">
              <span v-time="scope.row.update_time"></span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="160" fixed="right" align="center">
            <template slot-scope="scope">
              <el-button
                size="small"
                type="text"
                @click="handleClickEdit(scope.row, 'detail')"
                v-permission="'waybillSign_detail'"
                >详情</el-button
              >
              <el-button
                size="small"
                type="text"
                @click="handleClickEdit(scope.row, 'edit')"
                v-permission="'waybillSign_update'"
                >编辑</el-button
              >
              <el-button
              v-permission="'abnormal_record_create'"
                type="text"
                size="small"
                @click="clickabnormalFn(scope.row)"
                >异常操作</el-button
              >
            </template>
          </el-table-column>
        </el-table> -->
        <div
          style="
            display: flex;
            justify-content: flex-end;
            margin: 10px 0px 0px 0px;
          "
        >
          <el-pagination
            small
            background
            :current-page="paginations.pageIndex"
            :page-sizes="paginations.pageSizes"
            :page-size="paginations.pageSize"
            :layout="paginations.layout"
            :total="paginations.total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </div>
    </div>
    <StepOperation
      v-if="mode === 'add'"
      :mode="mode"
      :key="1"
      :showDialog="showDialog"
      :ids="checkedOrders.map(Number)"
      :step="4"
      @closeDialog="handleCloseDialog"
      :signType="signType"
    >
    </StepOperation>
    <StepOperation
      v-else
      :mode="mode"
      :key="2"
      :showDialog="showDialog"
      :id="nowId"
      :ids="checkedOrders.map(Number)"
      :step="4"
      @closeDialog="handleCloseDialog"
      :signType="signType"
    ></StepOperation>
  </div>
</template>
<script>
import TableHeader from "@/page/orderform/components/TableHeader/tableheader.vue";
import SettinUp from "@/page/orderform/components/settingUp/settingUp.vue";
import {
  SignforListFn,
  SignforBringListFn,
  SignforDeliveryListFn,
  SignforDeliveryStayListFn,
  SignforTakeStayListFn,
  SignforCancelFn,
  SignRejectList,
  SignforCountFn,
  waybillSignExport,
  DeliveryStayExport,
  TakeStayExport,
} from "@/api/waybill";
import { organizationBox } from "@/api/organization";
import AbnormalModal from "./components/abnormalModal.vue";
import StepOperation from "./components/stepOperation.vue";
import WaybillSearchHead from "./components/waybillSearchHead.vue";
import { statusArr } from "./constants/index.js";
import { sendClickTracker } from "@/utils/tracker";

export default {
  data() {
    return {
      orders: [],
      paginations: {
        pageIndex: 1, // 当前位于哪页
        pageSize: 20, // 1页显示多少条
        pageSizes: [10, 20, 50, 100], //每页显示多少条
        total: 200,
        layout: "total, sizes, prev, pager, next, jumper", // 翻页属性
      },
      tabIndex: "1",
      checkedOrders: [],
      showDialog: false,
      deleveryData: ["自提", "送货"],
      rejectData: ["", "客户原因", "我司原因"],
      // maxheight: 400,
      signType: "0",
      mode: "",
      nowId: "",
      statusArr: statusArr,
      searchParams: {},
      orderSearch: {},
      organizationBoxData: [],
      propsBranchType: {
        emitPath: true,
        checkStrictly: true,
        value: "id",
        label: "branch_name",
        children: "next_level_data",
      },
      nums: [],
      isLoading: false,
      header_data_list: [],
      propMap: {},
      obj_list: {},
      HeaderData: [],
      orders_list: [],
      header_data_list_two: [],
      propMap_two: {},
      obj_list_two: {},
      HeaderData_two: [],
      orders_list_two: [],
      header_data_list_three: [],
      propMap_three: {},
      obj_list_three: {},
      HeaderData_three: [],
      orders_list_three: [],
      operation_type: "1",
      create_time: {
        start_time: 1664553600000,
        end_time: new Date().getTime(),
      },
    };
  },
  components: { StepOperation, WaybillSearchHead, TableHeader, SettinUp },
  mounted() {
    // this.getSignforList();
    this.organizationBoxFn();
  },
  watch: {
    $route: {
      handler(newV, oldV) {
        if (this.$route.query.type == 0) {
          this.tabIndex = "0";
          this.getSignforList();
        } else if (this.$route.query.type == 1) {
          this.tabIndex = "1";
          this.getSignforList();
        } else if (this.$route.query.type == 2) {
          this.tabIndex = "2";
          this.getSignforList();
        } else if (this.$route.query.type == 3) {
          this.tabIndex = "3";
          this.getSignforList();
        }
        // console.log(this.$route.query.type, "this.$route.query.type");
      },
      immediate: true,
      deep: true,
    },
  },
  computed: {},
  methods: {
    async handleExport() {
      this.isLoading = true;
      let res;
      const params = this.getSearchParams();
      // 0待自提 1待签收
      if (this.tabIndex === "0" || this.tabIndex === "1") {
        const exportFn = [TakeStayExport, DeliveryStayExport][this.tabIndex];
        res = await exportFn({
          ...params,
          ids: (this.checkedOrders || []).map(Number),
        });
      } else {
        // 1-已签收，0-拒收
        const sign_type = this.tabIndex === "2" ? "1" : "0";
        res = await waybillSignExport({
          ...params,
          ids: (this.checkedOrders || []).map(Number),
          sign_type,
        });
      }
      if (res.code === 10000) {
        this.reqUrl = "https://" + res.data.loaded_url;
        window.open(this.reqUrl);
        this.isLoading = false;
      }
      sendClickTracker("P10-6");
    },
    organizationBoxFn() {
      let data = {
        show_employee: false, // 是否展示员工信息
        not_show_first_branch: 1,
      };
      organizationBox(data).then((res) => {
        if (res.code === 10000) {
          this.organizationBoxData = res.data;
        }
      });
    },
    //异常操作
    clickabnormalFn(valData) {
      const { waybill_id, id } = valData;
      this.$msgbox({
        title: "提交异常",
        message: (
          <AbnormalModal
            key={Math.random()}
            step={4}
            waybillIds={[waybill_id].map(String)}
            nodeId={id + ""}
            style="width:600px"
          ></AbnormalModal>
        ),
        customClass: "temperature_msg",
        showConfirmButton: false,
        showCancelButton: false,
        closeOnClickModal: false,
        showClose: true,
      });
    },
    handleSearch(params) {
      // console.log(params, "params");
      this.orderSearch = params;
      this.paginations.pageIndex = 1;
      this.getSignforList();
    },
    // 重置
    handleReset(params) {
      // console.log(params, "params");
      this.orderSearch = params;
      this.paginations.pageIndex = 1;
      this.getSignforList();
    },
    handleSignSearch() {
      this.paginations.pageIndex = 1;
      this.getSignforList();
    },
    handleSignReset() {
      this.paginations.pageIndex = 1;
      this.$refs.TableHeaderList.childMethod();
      this.getSignforList();
    },
    handleClickSign(signType) {
      this.signType = signType;
      this.mode = "add";
      this.showDialog = true;
    },
    handleSelectionChange(selects) {
      this.checkedOrders = selects.map((item) => item.id);
    },
    handleCloseDialog(isUpdate = true) {
      this.showDialog = false;
      isUpdate && this.getSignforList();
    },
    async handleClickCancel() {
      if (this.checkedOrders.length > 1) {
        this.$message({
          message: "只支持单个操作",
          type: "warning",
        });
        return;
      } else if (this.checkedOrders.length === 0) {
        this.$message({
          message: "请选中后进行操作",
          type: "warning",
        });
        return;
      }
      const res = await SignforCountFn({ id: this.checkedOrders[0] });
      const count = res.data.count;
      // 签收单id关联运单下的签收单个数<=1，不弹框提示
      if (count <= 1) {
        this.cancelSign(false);
        return;
      }
      let is_cancel_all;
      // const text = this.tabIndex === '2' ? '该运单下存在其它签收单，是否一起取消？' : '该运单下存在其它拒收单，是否一起取消？';
      this.$confirm("该运单下存在其它签收/拒收单，是否一起取消？", "提示", {
        confirmButtonText: "全部取消",
        cancelButtonText: "取消当前",
        distinguishCancelAndClose: true,
        type: "warning",
      })
        .then(() => {
          is_cancel_all = true;
          this.cancelSign(is_cancel_all);
        })
        .catch((action) => {
          if (action === "cancel") {
            is_cancel_all = false;
            this.cancelSign(is_cancel_all);
          }
        });
    },
    cancelSign(is_cancel_all) {
      SignforCancelFn({
        id: this.checkedOrders.map(Number)[0],
        is_cancel_all,
      }).then((res) => {
        if (res.code === 10000) {
          this.$message({
            message: "取消完成",
            type: "success",
          });
          this.getSignforList();
        } else {
          this.$message({
            message: res.message,
            type: "warning",
          });
        }
      });
    },
    handleTabClick(tab) {
      this.searchParams = {};
      this.orderSearch = {};
      this.obj_list = {};
      this.obj_list_two = {};
      this.obj_list_three = {};
      this.paginations.pageSize = 20;
      this.paginations.pageIndex = 1;
      if (this.tabIndex === "0" || this.tabIndex === "1") {
        this.orders = [];
        this.handleSignReset();
        this.getSignforList();
      } else {
        this.paginations.pageIndex = 1;
        this.getSignforList();
      }
    },
    getSearchParams() {
      let params = {};
      // 待签收、待自提运单
      if (this.tabIndex === "0" || this.tabIndex === "1") {
        params = {
          header_id: 1 + "",
          ...this.obj_list,
          create_time: {
            start_time: (this.create_time.start_time + "").slice(0, 10),
            end_time: (this.create_time.end_time + "").slice(0, 10),
          },
        };

        // 已签收 已拒收
      } else if (this.tabIndex === "2") {
        params = {
          header_id: 6 + "",
          ...this.obj_list_two,
        };
      } else {
        params = {
          header_id: 6 + "",
          ...this.obj_list_three,
        };
      }
      return {
        page: this.paginations.pageIndex,
        page_size: this.paginations.pageSize,
        ...params,
      };
    },
    getSignforList() {
      const listArr = [
        SignforTakeStayListFn,
        SignforDeliveryStayListFn,
        SignforListFn,
        SignRejectList,
      ];
      const params = this.getSearchParams();
      // console.log(params, "数据的切换后内容改变");
      listArr[this.tabIndex](params).then((res) => {
        this.paginations.total = res.data.total;
        this.nums[this.tabIndex] = res.data.total;
        if (this.tabIndex === "0" || this.tabIndex === "1") {
          this.orders_list = res.data.data == null ? [] : res.data.data;
          this.orders_list.unshift({});
          this.header_data_list = this.orders_list;
          this.HeaderData = res.data.item_list;
          this.Fntransformation(this.HeaderData);
        }
        if (this.tabIndex === "2") {
          this.orders_list_two = res.data.data == null ? [] : res.data.data;

          this.orders_list_two.unshift({});
          this.header_data_list_two = this.orders_list_two;
          this.HeaderData_two = res.data.item_list;
          this.Fntransformation_two(this.HeaderData_two);
        }
        if (this.tabIndex === "3") {
          this.orders_list_three = res.data.data == null ? [] : res.data.data;
          this.orders_list_three.unshift({});
          this.header_data_list_three = this.orders_list_three;
          this.HeaderData_three = res.data.item_list;
          this.Fntransformation_three(this.HeaderData_three);
        }
      });
    },
    objheader(obj) {
      this.orders_list = [];
      var data = {
        header_id: 1 + "",
        ...obj,
      };
      this.obj_list = obj;
      const listArr = [
        SignforTakeStayListFn,
        SignforDeliveryStayListFn,
        SignforListFn,
        SignRejectList,
      ];
      listArr[this.tabIndex](data).then((res) => {
        // this.header_data_list = res.data.list
        if (res.code === 10000 && res.data.data !== null) {
          this.orders_list = res.data.data == null ? [] : res.data.data;
          this.orders_list.unshift({});
          this.header_data_list = this.orders_list;
          this.paginations.total = res.data.total;
          this.paginations.pageSize = res.data.page_size;
          this.paginations.pageIndex = res.data.page;
          // this.pageSize = res.data.page_size;
          this.nums[this.tabIndex] = res.data.total;
        } else {
          this.header_data_list = [{}];
          this.nums[this.tabIndex] = 0;
          this.paginations.total = 0;
        }
      });
    },
    handleDelete(index, id, type) {
      this.handleJump(id.id);
    },
    handleDeleteType(value) {
      this.checkedOrders = value.map(String);
    },
    // 隐射函数
    Fntransformation(obj) {
      const result = {};
      for (const prop in obj) {
        if (obj.hasOwnProperty(prop)) {
          if (obj[prop].send_name !== "") {
            result[obj[prop].name] = obj[prop].show_name;
          } else {
            result[obj[prop].name] = obj[prop].name;
          }
        }
      }
      this.propMap = result;
    },
    handleClickEdit({ id }, mode) {
      this.nowId = id;
      this.mode = mode;
      this.showDialog = true;
    },
    objheader_two(obj) {
      this.orders_list_two = [];
      var data = {
        header_id: 6 + "",
        ...obj,
      };
      this.obj_list_two = obj;
      const listArr = [
        SignforTakeStayListFn,
        SignforDeliveryStayListFn,
        SignforListFn,
        SignRejectList,
      ];
      listArr[this.tabIndex](data).then((res) => {
        if (res.code === 10000 && res.data.data !== null) {
          this.orders_list_two = res.data.data == null ? [] : res.data.data;
          this.orders_list_two.unshift({});
          this.header_data_list_two = this.orders_list_two;
          this.paginations.total = res.data.total;
          this.paginations.pageSize = res.data.page_size;
          this.paginations.pageIndex = res.data.page;
        } else {
          this.header_data_list_two = [{}];
          this.paginations.total = 0;
        }
      });
    },
    handleDelete_two(index, id, type) {
      this.handleJump(id);
    },
    handleDeleteType_two(value) {
      this.checkedOrders = value.map(String);
    },
    // 隐射函数
    Fntransformation_two(obj) {
      const result = {};
      for (const prop in obj) {
        if (obj.hasOwnProperty(prop)) {
          if (obj[prop].send_name !== "") {
            result[obj[prop].name] = obj[prop].show_name;
          } else {
            result[obj[prop].name] = obj[prop].name;
          }
        }
      }
      this.propMap_two = result;
    },

    objheader_three(obj) {
      // this.orders_list_three = []
      var data = {
        header_id: 6 + "",
        ...obj,
      };
      this.obj_list_three = obj;
      const listArr = [
        SignforTakeStayListFn,
        SignforDeliveryStayListFn,
        SignforListFn,
        SignRejectList,
      ];
      listArr[this.tabIndex](data).then((res) => {
        if (res.code === 10000 && res.data.data !== null) {
          this.orders_list_three = res.data.data == null ? [] : res.data.data;
          this.orders_list_three.unshift({});
          this.header_data_list_three = this.orders_list_three;
          this.paginations.total = res.data.total;
          this.paginations.pageSize = res.data.page_size;
          this.paginations.pageIndex = res.data.page;
        } else {
          this.header_data_list_three = [{}];
          this.paginations.total = 0;
        }
      });
    },
    handleDelete_three(index, id, type) {
      this.handleJump(id);
    },
    handleDeleteType_three(value) {
      this.checkedOrders = value.map(String);
    },
    // 隐射函数
    Fntransformation_three(obj) {
      const result = {};
      for (const prop in obj) {
        if (obj.hasOwnProperty(prop)) {
          if (obj[prop].send_name !== "") {
            result[obj[prop].name] = obj[prop].show_name;
          } else {
            result[obj[prop].name] = obj[prop].name;
          }
        }
      }
      this.propMap_three = result;
    },
    // 每页条数改变
    handleSizeChange(val) {
      this.paginations.pageSize = val;
      this.getSignforList();
    },
    // 当前页改变
    handleCurrentChange(val) {
      this.paginations.pageIndex = val;
      this.getSignforList();
    },
    async handleJump(id) {
      let text = this.$router.resolve({
        name: "waybillDetail",
        query: { id, activeName: "1" },
      });
      window.open(text.href, "_blank");
    },
    rowStyle({ row }) {
      let jsonObj = {};
      if (row.is_over_temperature && row.is_over_temperature === "1") {
        jsonObj.background = "#ffc4c4 !important";
        return jsonObj;
      } else {
        return "";
      }
    },
    objSettinUp() {
      // console.log("");
      this.getSignforList();
    },
    handleClickDetail_three(val) {
      this.handleClickEdit(val, "detail");
    },
    handleClickEdit_three(val) {
      // console.log(val, "fjalksdjflakjdsf");
      this.handleClickEdit(val, "edit");
    },
    clickabnormalFn_three(val) {
      this.clickabnormalFn(val);
    },
    handleJumpway(scope, index) {
      this.handleJump_list(scope, index);
    },
    handleJump_list(scope, index) {
      const waybill_id_list = scope.row.waybill_list || [];

      const id = waybill_id_list[index].waybill_id;

      let text = this.$router.resolve({
        name: "waybillDetail",
        query: { id, activeName: "1" },
      });
      window.open(text.href, "_blank");
    },
  },
};
</script>

<style lang="less" scoped>
// /deep/ .el-tabs__nav-wrap {
//   left: -154px;
// }
.allOrderContainer {
  padding: 10px 15px;
  background-color: #fff;

  /deep/ .el-tabs--border-card > .el-tabs__content {
    padding: 0px;
  }

  .content-wrapper {
    // padding: 10px;
  }

  .orderHeader {
    margin-top: 5px;
    background-color: #fff;

    .orderSearch {
      form {
        ::v-deep .el-form-item__label {
          font-size: 14px;
        }

        .el-textarea {
          width: 135px;
        }
      }
    }
  }

  .actions {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
    background-color: #fff;
    .el-button + .el-dropdown,
    .el-dropdown + .el-button {
      margin-left: 10px;
    }
  }

  .tab.el-tabs--border-card {
    border: none;
    box-shadow: none;

    .el-tabs__content {
      padding: 0;
      height: 40px;
    }
  }

  /deep/.badge_item .el-badge__content {
    height: 15px;
    line-height: 15px;
  }

  /deep/.badge_item .el-badge__content.is-fixed {
    top: 6px;
  }
}
</style>
